#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main()
{
    printf("before fork: I am a prcess, pid: %d, ppid: %d\n", getpid(), getppid());

    sleep(5);
    printf("开始创建进程啦!\n");
    sleep(1);
    pid_t id = fork();
    if(id < 0)
        return 1;
    else if(id == 0)
    {
        while(1)
        {
            printf("This is child process! pid:%d  ppid:%d  return id:%d\n",getpid(),getppid(),id);
            sleep(1);
        }
    }
    else
    {
        while(1)
        {
            printf("This is father process! pid:%d  ppid:%d  return id:%d\n",getpid(),getppid(),id);
            sleep(1);
        }
    }
    sleep(2);
    return 0;
}
